<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="MobileOptimized" content="320" />
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/jiazai.css">
    <link rel="stylesheet" type="text/css" href="./css/forget-password.css" />
    <title>Webview Example</title>
</head>

<body>
    <div id='app'>
        <!-- 加载中动画 -->
        <div class='jiazai' v-if='jiazai'>
            <img src="./img/jia-ani.gif" width="50px" height="50px">
        </div>
        <!-- 加载中动画 -->
        <div id="hea-com">
            <img @click='close' src="./img/right-black.svg" width="18px">
            <span>找回密码</span>
        </div>
        <h1 class='title'>私钥找回密码</h1>
        <div class='content'>
            <div class='input' @click='changePass'>
                <div>密码类型</div>
                <span v-text='passType'>登陆密码</span>
                <img src="./img/down.svg" width="24px">
            </div>
            <div class='input'>
                <div class='siyao'>
                    <img src="./img/key.svg" width="24px">
                    <span>私钥</span>
                </div>
                <input type="password" v-model='siyao'>
                <span style="opacity:0"></span>
            </div>
            <div class='input'>
                <div class='siyao'>
                    <img src="./img/for-phone.svg" width="24px">
                    <span>手机号</span>
                </div>
                <input type="text" v-model='phone'>
                <span style="opacity:0"></span>
            </div>
            <p>请输入私钥找回密码，忘记私钥将无法找回，请牢记你的私钥，并将其记在安全的地方。</p>
            <button @click='sure'>确认</button>
        </div>

    </div>

    <script src="./js/comm.js" type="text/javascript" charset="utf-8"></script>
    <script src="./js/back.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/base64.js"></script>
    <script src="./js/vue.min.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                jiazai: false,
                //修改什么密码的字
                passType: '登陆密码',
                //用户输入的私钥
                siyao: '',
                phone: ''
            },
            methods: {
                close: function() {
                    var web = plus.webview.currentWebview();
                    web.close('none');
                },
                //确定
                sure: function() {
                    if (this.siyao.length == 0) {
                        _toast('请输入正确的私钥');
                        return;
                    }
//                  if (!_checkMobile(this.phone)) {
//                      _toast('请输入正确的手机号');
//                      return;
//                  }
                    var This = this;
                    This.jiazai = true;
                    _bas64Post(FORGET_PASSWORD, {
                        type: this.passType == '登陆密码' ? 1 : 2,
                        privatekey: this.siyao,
                        userphone: this.phone
                    }, function(data) {
                        This.jiazai = false;
                        if (data.status == 1) {
                            var web = null;
                            if (This.passType == '登陆密码') {
                                web = _openHref('find-login-password.html', 'findLoginPassword');
                            } else {
                                web = _openHref('find-trans-password.html', 'findTransPassword');
                            }
                            setTimeout(function() {
                                web.evalJS("user('" + JSON.stringify(data.back) + "')");
                            }, 200);
                        } else {
                            _toast(data.msg);
                        }
                    });
                },
                //选择找回的密码  是登陆密码 还是交易密码
                changePass: function() {
                    var This = this;
                    plus.nativeUI.actionSheet({
                        cancel: "取消",
                        buttons: [{
                            title: "登陆密码"
                        }, {
                            title: "交易密码"
                        }]
                    }, function(e) {
                        if (e.index == 1) {
                            //修改登陆密码
                            This.passType = '登陆密码';
                        } else {
                            //修改交易密码
                            This.passType = '交易密码';
                        }
                    });
                }
            }
        });
    </script>
    <script type="text/javascript" charset="utf-8">
        function plusReady() {

        }
        if (window.plus) {
            plusReady();
        } else {
            document.addEventListener('plusready', plusReady, false);
        }
    </script>
</body>

</html>